package com.dycong.common.leetcode.yi;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yilin
 * Date: 2019-09-04
 * Time: 19:45
 */
public class ReverseLinkList {

    public static LinkNode reverseNode(LinkNode linkNode) {
        if (linkNode == null || linkNode.next == null) return linkNode;

        LinkNode pNext = linkNode.next;
        LinkNode reverHead = reverseNode(pNext);
        pNext.next = linkNode;
        linkNode.next = null;
        return reverHead;
    }


    public class LinkNode {
        int val;
        LinkNode next;

        public LinkNode(int val) {
            this.val = val;
        }
    }
}
